home *** CD-ROM | disk | FTP | other *** search
/ CD Fun House 1 / CD Fun House (Wayzata Technology).iso / •Games Parlour• / •Maj Jong• / HyperGunshy •••• / HyperGunshy ееее / card_5605.txt < prev    next >
Text File  |  1990-10-08  |  9KB  |  236 lines

  1. -- card: 5605 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 4000
  4. -- background id: 3503
  5. -- name: About Hyper-GunShy
  6. ----- HyperTalk script -----
  7. -- Documentation on the Hyper-GunShy Stack
  8. -- T. R. Teague - 6 Sep 87
  9. -- For answers to your questions, contact me on CompuServe 76354,324
  10. --
  11. -- This is my first HyperCard Stack, and I thought I would share with
  12. -- you, some of the experience I gained in doing this stack.
  13. --
  14. -- I had played with HyperCard a little, using the tutorial stacks
  15. -- (although I didn't have any documentation at this stage).
  16. -- The idea came to me, from seeing that GunShy looked like a whole
  17. -- series of buttons with icons on them - 2 major parts of HyperCard.
  18. --
  19. -- The first thing I did was create about 100 buttons of approx. the
  20. -- right size, with a single standard icon on them. This gave me a feel
  21. -- for authoring a stack (that was easy). Then I experimented with the
  22. -- button layers (not understanding them at the time) but thought that
  23. -- they might be useful to hide layers as per GunShy. Then I created
  24. -- the Home, About, Help, Return buttons, and copied the scripts from
  25. -- other stacks, and tested them out.
  26. --
  27. -- At this stage, I needed to customize the stack - so I imported a
  28. -- PICT resource and all the ICON & ICN# resources from GunShy with
  29. -- the use of ResEdit, and pasted them into the background and stack
  30. -- respectively - that was simple, and made a major impact on the
  31. -- stack.
  32. --
  33. -- This was when I started thinking about the logic of the game.
  34. -- I had spent a lot of time to this point going back and forth to the
  35. -- on-line help, and this gave me a feel for the power of HyperCard,
  36. -- but I wished to have the on-line help visible at all times,
  37. -- especially when editing a script.
  38. --
  39. -- I created the other cards for the stack, such as About, Help, and
  40. -- entered the relevant info - the help fields were easy (but took me
  41. -- a while to figure out how to see where I had to type etc), but I
  42. -- had forgotten how the Text Paint Tool worked, so it took several
  43. -- attempts to get the About card right (I wanted to have different
  44. -- fonts/styles etc as part of the About message, but couldn't).
  45. --
  46. -- By this time I had figured out that I didn't want to duplicate the
  47. -- code for every button on the first card, and understood the power
  48. -- of message handlers and inheritance - so I decided to put the main
  49. -- code on that first card. Also I had also put the GunShy menus into
  50. -- buttons on this card. But as I started writing code and testing it,
  51. -- it was obvious that these buttons might interfere with the icon
  52. -- buttons, so this is when I started experimenting with putting
  53. -- different functional parts on cards, and others on backgrounds -
  54. -- that turned out ok.
  55. --
  56. -- It was probably at this stage that I obtained documentation - the
  57. -- Complete HyperCard HandBook by Danny Goodman and read it. Most of
  58. -- it I had figured out by now, but learnt a few things like layers
  59. -- and how the Tools/Paint/Option menus performed. It would help with
  60. -- HyperTalk syntax. Also I kept getting hold of as many third-party
  61. -- stacks as I could, to learn what they had done, and I borrowed a
  62. -- few ideas. I had some problems moving cards and backgrounds around -
  63. -- the limitation of when you copy a card, the background comes with it
  64. -- automatically was annoying. An option type key would have been useful.
  65. --
  66. -- It was time for serious programming. Some of it went simply at first
  67. -- so that the basic selection, highlighting, and hiding of icon buttons
  68. -- occurred, and appropriate values were put into variables. I learnt
  69. -- a lot about Global variables, and items, words, and containers.
  70. -- My If/Then/Else/End If logic was getting more complicated and I
  71. -- appreciated the power of Scripting, such that Begin/End's were
  72. -- matched up for me. Also at this stage, the Message Box came in very
  73. -- handy to debug variables - I set some of my local variables to global
  74. -- just so I could debug it from the Msg Box directly - otherwise I
  75. -- liberally sprinkled the script with Put messages to see what was
  76. -- happening. I found the interpretative nature of HyperTalk a big boon
  77. -- as I was able to abort scripts when they didn't work, make some
  78. -- changes, and then continue with the code, and when I had made a
  79. -- syntax error in the changes, correct it immediately.
  80. --
  81. -- Some the limitations of HyperTalk became apparent - it is too slow
  82. -- for some things, and several times I had to think about ways to make
  83. -- the program more efficient, and introduced more variables. I also
  84. -- had a worry about how big a string a container could hold, as my
  85. -- strings were getting quite long, and some things weren't working
  86. -- right - as it turned out, I had run into a HyperCard bug - it does
  87. -- not seem to be able to handle complex expressions, and was doing
  88. -- screwy things to my variables. I had to make quite a number of
  89. -- adjustments to work around these problems, and I began to wonder
  90. -- what other problems were lurking.
  91. --
  92. -- I found one limitation that I needed to address - when choosing
  93. -- icons randomly for buttons, HyperCard was not smart enough to tell
  94. -- me if a particular icon was available or not - I decided this was
  95. -- a good candidate for an external HyperCard cmd (XCMD or XFCN).
  96. -- I had seen the WildSwaps & WildHacks stacks and external commands
  97. -- and had a good idea of how it worked. But I got the documentation
  98. -- for external commands, and that added something to my learning.
  99. -- The code was easy to write, but a simple mistake on my part stopped
  100. -- it from working initally, but after that was fixed, it worked first
  101. -- time. The source code may be included below.
  102. --
  103. -- Now it was time for the nitty gritty work of debugging the code
  104. -- and adding the actual game logic (the rules of the game - see
  105. -- LegalMove handler), which I had left to last after the rest of the
  106. -- mechanics seemed to be working. I did run into a few other problems
  107. -- in which use of user defined functions and commands did not interact
  108. -- exactly with HyperTalk as the documentation led me to believe. I
  109. -- think most of the grief was caused by the the HyperTalk bugs and
  110. -- difficulty in manipulating items in a list of numbers in a container.
  111. --
  112. -- Finally it was clean-up time, and final testing.
  113. --
  114. -
  115. -- One trick I learnt : if you have a command such as :
  116. --
  117. -- send "newstuff" to this card
  118. --
  119. -- and your debugging clears the msg box, and you need to enter that
  120. -- command often (to fix up "corrupted" data), you get tired of typing
  121. -- that long command in every time. So at some time enter the following
  122. -- into the msg box :
  123. --
  124. -- put "send ""e&"newstuff""e&" to this card" into savecmd
  125. --
  126. -- to use the command, just enter thereafter into the msg box :
  127. --
  128. -- savecmd
  129. --
  130. --
  131. -- Conclusions : what did I learn - HyperCard is a very powerful tool,
  132. -- but has some limitations (mainly one of speed) to be aware of.
  133. -- The program could be made more efficient, by having more variables
  134. -- which hold information, which doesn't have to be calculated all the
  135. -- time (e.g. compare speed of Option Key handler while doing the
  136. -- work, and the speed of the same handler when cleaning up)
  137. -- There are probably still some bugs - there seems to be one in the
  138. -- Open/Save scripts - an extra blank card seems to be produced in some
  139. -- circumstances.
  140. --
  141. -- External function follows :
  142. --
  143.  
  144. {$R-}
  145.  
  146. {$S GetIcon }     { Segment name must be the same as the command name. }
  147.  
  148. UNIT DummyUnit;
  149.  
  150. INTERFACE
  151.  
  152. USES MemTypes, HyperXCmd, QuickDraw, OSIntf, ToolIntf;
  153.  
  154. PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  155.  
  156. IMPLEMENTATION
  157.  
  158. TYPE Str31 = String[31];
  159. Str19 = String[19];
  160. WordPtr = ^INTEGER;
  161. LongPtr = ^LongInt;
  162.  
  163. PROCEDURE MyGetIcon(paramPtr: XCmdPtr); FORWARD;
  164.  
  165. PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  166. BEGIN
  167. MyGetIcon(paramPtr);
  168. END;
  169.  
  170. PROCEDURE MyGetIcon(paramPtr: XCmdPtr);
  171. VAR str: Str255;
  172. IconNum : integer;
  173. MyHandle : Handle;
  174. gotIcon : boolean;
  175.  
  176. {$I XCmdGlue.inc }
  177.  
  178. BEGIN
  179. WITH paramPtr^ DO
  180. BEGIN
  181. { first param is ICN# }
  182. ZeroToPas(params[1]^,str);
  183. IconNum := StrToNum(str);
  184.  
  185. gotIcon := false;
  186.  
  187. MyHandle := GetResource('ICON',IconNum);
  188. if (MyHandle = nil) then
  189.   begin
  190.   MyHandle := GetResource('ICN#',IconNum);
  191.   end;
  192.  
  193.   if (MyHandle <> nil) then
  194.     begin
  195.     gotIcon := true;
  196.     ReleaseResource(MyHandle);
  197.     end;
  198.  
  199.     str := BoolToStr(gotIcon);
  200.     returnValue := PasToZero(str);
  201.     END;
  202.     END;
  203.  
  204.  
  205.     END.
  206.  
  207.  
  208.     --
  209.     -- Have fun!
  210.  
  211.  
  212.  
  213.  
  214. -- part 1 (button)
  215. -- low flags: 00
  216. -- high flags: 0000
  217. -- rect: left=466 top=316 right=341 bottom=503
  218. -- title width / last selected line: 0
  219. -- icon id / first selected line: 1012 / 1012
  220. -- text alignment: 1
  221. -- font id: 0
  222. -- text size: 12
  223. -- style flags: 0
  224. -- line height: 16
  225. -- part name: 
  226. ----- HyperTalk script -----
  227. on mouseUp
  228.   visual effect iris close
  229.   pop card
  230. end mouseUp
  231.  
  232.  
  233.  
  234. -- part contents for background part 2
  235. ----- text -----
  236. Paste this button into your Home Stack.